<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/8/31
 * Time: 9:48
 */
namespace Home\Controller;
use Think\Controller;

class RegisterController extends Controller{
    public function index(){
        if(!IS_POST){
            $this->display();
        }else{
            $post = I("post.");
            $post["password"] = sha1("{$post['password']}");
            $post["account"]=str_replace(" ","",$post["account"]);
            $post['last_login_ip'] = $_SERVER['REMOTE_ADDR'];
            $post['last_login_time'] = time();
            $add = M("users")->data($post)->add();
            if($add){
                $this->success("注册成功！",U("/login"),0);
            }
        }
    }
}